package com.cskaoyan.controller.wxcontroller;

import com.cskaoyan.bean.po.MarketAddress;
import com.cskaoyan.bean.common.BaseRespVo;
import com.cskaoyan.bean.common.CommonData;
import com.cskaoyan.service.wxservice.AddressWeChatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 小黑球
 * @datetime 2023/1/1 22:26
 * @description: TODO:
 */
@RestController
@RequestMapping("wx/address")
public class AddressWeChatController {

    @Autowired
    AddressWeChatService addressWeChatService;

    /**
     * 地址管理的查看地址列表的方法
     *
     * @return
     */
    @RequestMapping("list")
    public BaseRespVo list() {
        CommonData<MarketAddress> data = addressWeChatService.list();
        return BaseRespVo.ok(data);
    }

    /**
     * 地址管理的地址详情方法
     *
     * @return
     */
    @RequestMapping("detail")
    public BaseRespVo detail(Integer id) {
        MarketAddress marketAddress = addressWeChatService.detail(id);
        return BaseRespVo.ok(marketAddress);
    }

    /**
     * 地址管理的地址修改方法
     *
     * @return
     */
    @RequestMapping("save")
    public BaseRespVo save(@RequestBody MarketAddress marketAddress) {
        Integer marketAddress1 = addressWeChatService.save(marketAddress);
        return BaseRespVo.ok(marketAddress1);
    }

    /**
     * 地址管理的删除地址方法
     *
     * @return
     */
    @RequestMapping("delete")
    public BaseRespVo delete(@RequestBody MarketAddress marketAddress) {
        addressWeChatService.delete(marketAddress);
        return BaseRespVo.ok();
    }
}
